<?php

namespace App\Models\User;
use App\Models\Auth\Menu;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use DateTimeInterface;
class Role extends Model
{
    protected $table = 'role';
    protected $primaryKey = 'role_id';

    protected function serializeDate(DateTimeInterface $date): string
    {
        return $date->format('Y-m-d H:i:s');
    }
    public function getMenuCheckStrictlyAttribute ($value){

        return $value == 1 ? true : false;
    }
    /**
     * @Notes:关联菜单表
     * @return BelongsToMany
     * @author: Liao Hong
     * @Time: 2025/10/21   14:53
     * @Interface permissions
     */
    public function permissions(): BelongsToMany
    {
        // 关联表：role_menu；角色表外键：role_id；菜单表外键：role_id
        return $this->belongsToMany(
            Menu::class,
            'role_menu',
            'role_id',
            'menu_id'
        );
    }
}
